﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace BPM.Web.Shared.Data;

/// <summary>
/// 用户表
/// </summary>
[DisplayName("用户表")]
public class SysUser : BaseVM
{
    /// <summary>
    /// 主键Id
    /// </summary>
    [DisplayName("业务号")]
    [Required(ErrorMessage = "业务号不能为空")]
    [JsonPropertyName("id")]
    public long Id { get; set; }

    /// <summary>
    /// 账号
    /// </summary>
    [DisplayName("账号")]
    [Required, MaxLength(50)]
    public string? Account { get; set; }

    /// <summary>
    /// 密码（默认MD5加密）
    /// </summary>
    [DisplayName("密码")]
    [Required, MaxLength(50)]
    public string? Password { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    [DisplayName("昵称")]
    [MaxLength(20)]
    public string? NickName { get; set; }

    /// <summary>
    /// 姓名
    /// </summary>
    [DisplayName("姓名")]
    [MaxLength(20)]
    public string? Name { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    [DisplayName("头像")]
    public string? Avatar { get; set; }

    /// <summary>
    /// 生日
    /// </summary>
    [DisplayName("生日")]
    public DateTimeOffset? Birthday { get; set; }

    /// <summary>
    /// 性别-男_1、女_2
    /// </summary>
    [DisplayName("性别-男_1、女_2")]
    public Gender Sex { get; set; }

    /// <summary>
    /// 邮箱
    /// </summary>
    [DisplayName("邮箱")]
    [MaxLength(50)]
    public string? Email { get; set; }

    /// <summary>
    /// 手机
    /// </summary>
    [DisplayName("手机")]
    [MaxLength(20)]
    public string? Phone { get; set; }

    /// <summary>
    /// 电话
    /// </summary>
    [DisplayName("电话")]
    [MaxLength(20)]
    public string? Tel { get; set; }

    /// <summary>
    /// 最后登录IP
    /// </summary>
    [DisplayName("最后登录IP")]
    [MaxLength(20)]
    public string? LastLoginIp { get; set; }

    /// <summary>
    /// 最后登录时间
    /// </summary>
    [DisplayName("最后登录时间")]
    public DateTimeOffset? LastLoginTime { get; set; }

    /// <summary>
    /// 管理员类型-超级管理员_1、管理员_2、普通账号_3
    /// </summary>
    [DisplayName("管理员类型-超级管理员_1、管理员_2、普通账号_3")]
    public AdminType AdminType { get; set; }

    /// <summary>
    /// 状态-正常_0、停用_1、删除_2
    /// </summary>
    [DisplayName("状态-正常_0、停用_1、删除_2")]
    public CommonStatus Status { get; set; } = CommonStatus.ENABLE;

    /// <summary>
    /// 多对多（角色）
    /// </summary>
    public IEnumerable<SysRole> SysRoles { get; set; } = Enumerable.Empty<SysRole>();

    /// <summary>
    /// 多对多中间表（用户-角色）
    /// </summary>
    public IEnumerable<SysUserRole> SysUserRoles { get; set; } = Enumerable.Empty<SysUserRole>();

    /// <summary>
    /// 多对多（机构）
    /// </summary>
    public IEnumerable<SysOrg> SysOrgs { get; set; } = Enumerable.Empty<SysOrg>();

    /// <summary>
    /// 多对多中间表（用户-机构 数据范围）
    /// </summary>
    public IEnumerable<SysUserDataScope> SysUserDataScopes { get; set; } = Enumerable.Empty<SysUserDataScope>();
}
